{extend name="public:index"/}
{block name="title"}{:sysconf('title')}{/block}
{block name="content"}
<section class="My_page ncbj_touxxx">
    <form id="member_from">
        <div class="top">
            <p class="p1"><a href="javascript:history.back(-1)"></a></p>
            <p class="p2">资料修改</p>
            <p class="p3"></p>
        </div>
        <div class="xiug">
            <div class="span1" style="height:3rem;line-height:3rem;">头像</div>
            <div class="span2">
                <section class="logo-license">
                    <div class="half">
                        <a class="logo" id="logox">
                            <img id="bgl" src="{$info.avatar|default='__INDEX__/images/tx.png'}">
                        </a>
                    </div>
                    <div class="clear"></div>
                </section>
                <article class="htmleaf-container">
                    <div id="clipArea"></div>
                    <div class="foot-use">
                        <div class="uploader1 blue" style="background-color:#ff0000!important;">
                            <input style="background-color:#ff0000!important;" type="button" name="file" class="button" value="打开">
                            <input id="file" type="file" accept="image/*" multiple  />
                        </div>
                        <button id="clipBtn">截取</button>
                    </div>
                </article>
            </div>
        </div>
        <p class="xiug">
            <span class="span1">用户名</span>
            <span class="span2"><input type="text" name="user_name" value="{$info.user_name}" style="outline:none" disabled></span>
        </p>
        <p class="xiug">
            <span class="span1">电话</span>
            <span class="span2"><input type="text" name="mobile" value="{$info.mobile}" style="outline:none" {if condition="$info.is_true_name eq 1"}disabled{/if}></span>
        </p>
        <p class="xiug">
            <span class="span1">昵称</span>
            <span class="span2"><input name="user_nickname" value="{$info.user_nickname}" placeholder="张三" style="outline:none"></span>
        </p>
        <p class="xiug">
            <span class="span1">邮箱</span>
            <span class="span2"><input name="email" value="{$info.email}" placeholder="@" style="outline:none"></span>
        </p>
        <p class="nannv">
            <span class="span1">姓别</span>
            <span class="span2">
					<select name="sex" class="xla_k" style="outline:none">
						<option value="">请选择</option>
						<option value="1" {if condition="$info.sex eq 1"}selected{/if}>男</option>
                        <option value="2" {if condition="$info.sex eq 2"}selected{/if}>女</option>
					</select>
				</span>
        </p>
        <div class="tijiao"><input id="member_submit" type="button" value="保存"></div>
    </form>
</section>
<script src="__INDEX__/scripts/iscroll-zoom.js"></script>
<script src="__INDEX__/scripts/hammer.js"></script>
<script src="__INDEX__/scripts/jquery.photoClip.js"></script>
<script>
    $("#clipArea").photoClip({
        width: 300,
        height: 300,
        file: "#file",
        view: "#view",
        ok: "#clipBtn",
        loadStart: function() {
            console.log("照片读取中");
        },
        loadComplete: function() {
            console.log("照片读取完成");
        },
        clipFinish: function(dataURL) {
            $.ajax({
                type: "POST",
                url: "{:url('User/saveAvatar')}",
                data: {'base':dataURL},
                dataType:"JSON",
                success:function(data){
                    if(data.code == 0){
                        $("#logox").empty();
                        $('#logox').append('<img src="' + dataURL + '>');
                        // $(".htmleaf-container").hide();
                    } else {
                        layer.msg(data.msg,{icon:5});
                    }
                },
                error: function(){
                    layer.msg("网络延迟，发送失败",{icon:5});
                }
            });
        }
    });
    $("#logox").click(function(){
        $(".htmleaf-container").show();
    });
    $("#member_submit").click(function () {
        $.ajax({
            type: "POST",
            url: "{:url('User/show')}",
            data: $("#member_from").serialize(),
            dataType:"JSON",
            success:function(data){
                if(data.code == 0){
                    layer.msg(data.msg,{icon:6,'time':1000},function () {
                        window.location.href="{:url('User/index')}";
                    });
                } else {
                    layer.msg(data.msg,{icon:5});
                }
            },
            error: function(){
                layer.msg("网络延迟，发送失败",{icon:5});
            }
        });
    });
</script>
{/block}